//
//  ViewController.m
//  02-UIButton
//
//  Created by 韩旭 on 16/7/15.
//  Copyright © 2016年 基础. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, assign) BOOL isPanduan;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    UIButton *playBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    playBtn.frame = CGRectMake(20, 20, 335, 60);
    playBtn.backgroundColor = [UIColor blueColor];
    [playBtn setTitle:@"播放" forState:UIControlStateNormal];
    [self.view addSubview:playBtn];
   [playBtn addTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    NSArray *array = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];
//    让数组中每个元素都执行这个方法 移除所有控件的方法
//    [self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    NSLog(@"%@", array);
}


- (void)playSong:(UIButton *)btn {
    NSLog(@"播放");
//   移除点击事件
    [btn removeTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(pasueSong:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"暂停" forState:UIControlStateNormal];
}
- (void)pasueSong:(UIButton *)pasueSong {
    NSLog(@"暂停");
    [pasueSong removeTarget:self action:@selector(pasueSong:) forControlEvents:UIControlEventTouchUpInside];
    [pasueSong addTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [pasueSong setTitle:@"播放" forState:UIControlStateNormal];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
